package com.beiing.tianshuai.tianshuai.mine.presenter;

import com.beiing.tianshuai.tianshuai.base.BasePresenter;
import com.beiing.tianshuai.tianshuai.entity.CommonBean;
import com.beiing.tianshuai.tianshuai.entity.MyOrderBean;
import com.beiing.tianshuai.tianshuai.mine.entity.OrderDeleteBean;
import com.beiing.tianshuai.tianshuai.mine.entity.OrderExtendTransportBean;
import com.beiing.tianshuai.tianshuai.mine.model.MyOrderModel;
import com.beiing.tianshuai.tianshuai.mine.model.MyOrderModelImpl;
import com.beiing.tianshuai.tianshuai.mine.view.MyOrderViewImpl;

/**
 * Description : 订单presenter
 *
 * @author Jinda Yang
 * @date 2017/7/27 0027
 */

public class MyOrderPresenter extends BasePresenter implements MyOrderPresenterImpl, MyOrderModel.OnRequestListener {

    private MyOrderViewImpl mMyOrderView;
    private MyOrderModelImpl mMyOrderModel;

    public MyOrderPresenter(MyOrderViewImpl myOrderView) {
        mMyOrderView = myOrderView;
        mMyOrderModel = new MyOrderModel(this);
    }

    @Override
    public void getMyOrderInfoResult(String uid, int type, String lastId, int pageSize) {
        mMyOrderView.showProgress();
        mMyOrderModel.getMyOrderInfoResult(uid, type, lastId, pageSize);
    }

    @Override
    public void getCancelRequestResult(String oid) {
        mMyOrderModel.getCancelRequestResult(oid);
    }

    @Override
    public void getDelRequestResult(String oid, int position) {
        mMyOrderModel.getDelRequestResult(oid, position);
    }

    @Override
    public void getDelayInReceivingResult(String orderId, MyOrderBean.DataBean.ResultBean bean) {
        mMyOrderModel.getDelayInReceivingResult(orderId, bean);
    }

    @Override
    public void onSuccess(MyOrderBean bean) {
        mMyOrderView.hideProgress();
        mMyOrderView.onRequestSuccess(bean);
    }

    @Override
    public void onCancelSuccess(CommonBean bean) {
        mMyOrderView.getCancelResult(bean);
    }

    @Override
    public void onDelSuccess(OrderDeleteBean bean, int position) {
        mMyOrderView.getDelResult(bean, position);
    }

    @Override
    public void onError(Throwable throwable) {
        mMyOrderView.hideProgress();
        mMyOrderView.onRequestFailed(throwable);
    }

    @Override
    public void onRequestDelayInReceivingSuccess(OrderExtendTransportBean bean, MyOrderBean.DataBean.ResultBean orderBean) {
        mMyOrderView.onRequestDelayInReceivingSuccess(bean, orderBean);
    }

    @Override
    public void onRequestDelayInReceivingError(Throwable throwable) {
        mMyOrderView.onRequestDelayInReceivingError(throwable);
    }
}
